/**
 * @Author: gan
 * @Description:
 * @File:  router
 * @Version: 1.0.0
 * @Date: 2022/4/8 2:35 下午
 */

package initialize

import (
	"gin-canteen-src/global"
	"gin-canteen-src/middleware"
	"gin-canteen-src/router"
	"github.com/gin-gonic/gin"
)

func Routers() *gin.Engine {
	Router := gin.Default()
	Router.Use(middleware.Cors(), middleware.GinRecovery(true))
	PublicGroup := Router.Group("")
	{
		// 健康监测
		PublicGroup.GET("/health", func(c *gin.Context) {
			c.JSON(200, "ok")
		})
	}

	systemRouter := router.RouterGroupApp.User
	PrivateGroup := Router.Group("")
	{
		systemRouter.InitUserRouter(PrivateGroup)
	}

	global.GloLogger.Info("router register success")
	return Router
}
